﻿
Pages_AdminInfo = new function () {
    this.documentReady = function () {
        $.ajax({
            type: "GET",
            url: "/Handler/HandlerConfig.ashx",
            data: { t: "GetAdminInfoPersonal" },
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            cache: false,
            success: function (data) {
                $("#lbUserName").text(data.UserName);
                $("#txtFullName").val(data.FullName);                
                if (data.Birthday != null)
                    $("#txtBirthday").val(COMMON.jSonDateToString(data.Birthday, 1));
                $("#txtYM").val(data.YM);
                $("#txtPhone").val(data.Phone);
                $("#lbCreateDateAdmin").text(COMMON.jSonDateToString(data.CreateDate, 1));
            }
        });
    };

    $("#btnUpdate").live('click', function () {
        _data =
                {
                    fullName: $("#txtFullName").val(),
                    birthday: $("#txtBirthday").val(),
                    YM: $("#txtYM").val(),
                    phone: $("#txtPhone").val()
                };

        $.ajax({
            type: "POST",
            url: "/WebService/WSConfig.asmx/UpdateAdminInfo",
            data: JSON.encode(_data),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            cache: false,
            success: function (data) {
                if (data.d > 0) {
                    jAlert(MESSAGE.updateSuccess, MESSAGE.title);
                }
            }
        });
    });
}
